The dynamics of a mouse.

Once upon a time, the keyboard was the best thing sinced sliced bread for interaction with the processor. 
A printer and-or a terminal type monitor was the display. Then came the mouse.
Since then, its hard to find a better mouse trap or a better mouse.

RapidQ likes mouses too. Our QObjects make it easy to do things with the mouse that formerly
needed to be done with the arrows on the keyboard. I can instruct my QObjects to recognize 
all my mouse activities with a simple sub-routine. I have created a myriad of things to do 
in this program using my wee little mouse, and my keyboard. It brings a program alive.

Some of the modules we use to do this are a little cryptic without some explaination.
This session will attempt to clear up some of that code. I'm sure you will think of a bunch 
of new features that you will want to add to it yourself.



 
         eOFFSET  hex display of the relative offset addresses in the icon file.

 Sub eOffsetDown (b%, x%, y%, s%)
     This module has much text, but its here for completeness. You may wish to expand on it
     or use a popup QObject instead of SHOWMESSAGE. I find I seldom use it.
     Its vectored from the eOFFSET RichEdit object with an OnMouseDown instruction.
     It simply counts down the lines in the ascii filed and capturing the last one
     that meets the IF criteria. Then displays it in a SHOWMESSAGE box.
     The parameters aren necessary in the DECLARATIONS, but I may want them later.


         SelectColor   the color panel for the color selected with the scrollbars

 Sub SelectColorDown (b%, x%, y%, s%, sender as QPanel)
     capture the selected color, in hex into variable BGR and set the drag-drop flag.



         Palette(0 to F)  The visual displays for each of the icons 16 colors.

 Sub PaletteDown   (b%, x%, y%, s%, sender as QPanel)
     The sender parameter is used to identify the palette used
     The active color takes on the selected color and hint attribute with a mouse click.

 Sub PaletteMove (b%, x%, y%, s%, sender as QPanel)
     This module does a lot of work when the cursor is dragged over it.

     The senders hint (0 to F) is converted to a number into variable C
     8 bytes of eHEX are highlighted from eHEX character 219 + 12 ascii per palette.

   IF the drag-drop flag is set from a mouse down from the SelectColor panel then
     the flag is cleared and the color palette and color table take the SelectCoror's color.

     Selstart and sellength are already set earlier in this sub.
     variable BGR holds the selected color from the SelectedColor mousedown.
     Convert BRG into text for the ehex 8 character display using c$ for conversion.

    IF activecolor is the same as the palette that was changed, then change activecolor too. 



         Canvas for the magnified image of the icon

 Sub CanvasMove (x%,y%,s%)
     Highlights the pixel value in hex display
     vx, vy use x%, y% to calculate the byte location in eHEX for XOR mode.
     tx, txy, ty do the same for the AND mode. note dx= f(y%) due to eHEX byte structure.
     The appropriate byte the cursor is pointing to in the magnified image is highlighted.
     the current vs and ts (visible and transparent) values are also used elsewhere.

 Sub Canvasdown (b%, x%, y%, s%, sender as QCanvas)
   IF in the XOR mode, write the active color into the eHEX display.
   If in the AND mode, then capture the byte holding 8 transparent pixels bits into N.
      calculate which of the 8 bits is needed to be altered.
      toggle that bit in the 8 bit value in N and place it into n$ with the XOR command.
      restore the modified byte in the eHEX display in the AND section of data.
         Perform the following subs to update the image display
         ColorMap
         XorMap
         AndMap



         eHEX ascii display work-around

     Without these subs, whenever I mouse down in the eHEX ascii display, the ScrollBox 
     slidebar moves to zero and a number of ascii bytes become highlighted due to the move.
     There is a more elegant method of handling this using a FOCUS include; however, it
     is beyond the scope of what we have covered. So I used this workaround instead.
     Essentially, it restores the ScrollBox's former position resulting in no highlighting.

 Sub eHexMove (x%, y%, s%)
     The ScrollBox's slidebar value is for any eHex display into variable "workaround".

 Sub eHexDown (b%, x%, y%, s%)
     This position is restored whenever I select a new location in the eHEX ascii field.


There are a number of events with no function, but they are here in case I want to use them
later for some new coding. They may be deleted without affecting the program.

Also, the temp routine is at the end of the program for convenience. It may be used to 
interactively influence the running program by entering diagnostic code. The data in the
etemp QEdit box can be read and the xtemp routine can be executed by clicking its button.
This sub, its declaration, the btemp button and the etemp Edit box can also be removed.



 
At this point in the project, you are in the position to use it, learn from it and edit it
at will. These sessions can serve as a reminder; however, you should be able to walk through
the entire program. Learning where the modules are, how they react with other modules and 
where a change might need be compensated for elsewhere is probably the biggest consideration.

Not only that, you may wish to simply go through the program and get rid of the modules that
are not necessary. Another thing you might want to do is change the documentation into terms
that you like. Another task you might not have considered is editing what I have done. I'm 
a terrible speller.
 

Softalk

This should conclude the view and overview of the program. There are a number of things that
you might wish to change or to add. Some examples might be to make the current directory,
using the system variable default for the save function so that the output icon file will 
output to the current directory unless otherwise selected. 
The about messages for the eOFFSET addresses might want to be done differently. 
Different hints might be better for the control buttons. 
(don't change the hints that are used for identification though)
Change the background color for the form, buttons or other QObjects.
There are a myriad of ways to personalize a program, once you get into it.
In any case
Happy Hacking